<!DOCTYPE HTML>
<html lang="zh-hans" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>6.课程3:查询复杂的数据类型 | Apache Drill</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.6">
        <meta name="author" content="smartloli">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-tbfed-pagefooter/footer.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html" />
    
    
    <link rel="prev" href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="3.4.6"
        data-chapter-title="6.课程3:查询复杂的数据类型"
        data-filepath="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.md"
        data-basepath="../.."
        data-revision="Fri Aug 26 2016 12:40:11 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
                
                <li>
                    <a href="http://drill.smartloli.org" target="blank" class="custom-link">Apache Drill</a>
                </li>
            
            

            
            <li class="divider"></li>
            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        前言
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" >
            
            <span><b>1.</b> 1.开始</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="1.开始/1.Introduction 介绍.html">
            
                
                    <a href="../../1.开始/1.Introduction 介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        1.Introduction 介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="1.开始/2.Why Drill 为什么使用 Drill.html">
            
                
                    <a href="../../1.开始/2.Why Drill 为什么使用 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        2.Why Drill 为什么使用 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" >
            
            <span><b>2.</b> 2.架构</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="2.架构/1.Architecture Introduction 架构介绍.html">
            
                
                    <a href="../../2.架构/1.Architecture Introduction 架构介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        1.Architecture Introduction 架构介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="2.架构/2.Drill Query Execution Drill 查询执行.html">
            
                
                    <a href="../../2.架构/2.Drill Query Execution Drill 查询执行.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        2.Drill Query Execution Drill 查询执行
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="2.架构/3.Core Modules 核心模块.html">
            
                
                    <a href="../../2.架构/3.Core Modules 核心模块.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        3.Core Modules 核心模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="2.架构/4.Performance 性能.html">
            
                
                    <a href="../../2.架构/4.Performance 性能.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        4.Performance 性能
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" >
            
            <span><b>3.</b> 3.教程</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="3.教程/1.Tutorials Introduction 教程介绍.html">
            
                
                    <a href="../../3.教程/1.Tutorials Introduction 教程介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        1.Tutorials Introduction 教程介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="3.教程/2.Drill in 10 Minutes 快速指导.html">
            
                
                    <a href="../../3.教程/2.Drill in 10 Minutes 快速指导.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        2.Drill in 10 Minutes 快速指导
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="3.教程/3.A-Y-A-D 数据集分析.html">
            
                
                    <a href="../../3.教程/3.A-Y-A-D 数据集分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        3.A-Y-A-D 数据集分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" >
            
            <span><b>3.4.</b> 4.在 MapR 的 Sandbox 中学习 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/1.关于 MapR 的 Sandbox.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/1.关于 MapR 的 Sandbox.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.1.</b>
                        
                        1.关于 MapR 的 Sandbox
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/2.在 Sandbox 中安装 Drill.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/2.在 Sandbox 中安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.2.</b>
                        
                        2.在 Sandbox 中安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/3.在 Sandbox 中使用 Drill.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/3.在 Sandbox 中使用 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.3.</b>
                        
                        3.在 Sandbox 中使用 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/4.课程1:学习数据集.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.4.</b>
                        
                        4.课程1:学习数据集
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.5.</b>
                        
                        5.课程2:使用 ANSI SQL 查询
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="3.4.6" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/6.课程3:查询复杂的数据类型.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.6.</b>
                        
                        6.课程3:查询复杂的数据类型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html">
            
                
                    <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.7.</b>
                        
                        7.总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="3.教程/5.高度动态的数据集分析.html">
            
                
                    <a href="../../3.教程/5.高度动态的数据集分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        5.高度动态的数据集分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="3.教程/6.社会媒体分析.html">
            
                
                    <a href="../../3.教程/6.社会媒体分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        6.社会媒体分析
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="3.教程/7.使用窗口函数分析数据.html">
            
                
                    <a href="../../3.教程/7.使用窗口函数分析数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        7.使用窗口函数分析数据
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> 4.安装 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="4.安装 Drill/1.Drill 安装介绍.html">
            
                
                    <a href="../../4.安装 Drill/1.Drill 安装介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        1.Drill 安装介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="4.安装 Drill/2.迁移 Parquet 数据.html">
            
                
                    <a href="../../4.安装 Drill/2.迁移 Parquet 数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        2.迁移 Parquet 数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" >
            
            <span><b>4.3.</b> 3.安装 Drill 到嵌入模式</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/1.嵌入模式的先决条件.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/1.嵌入模式的先决条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.1.</b>
                        
                        1.嵌入模式的先决条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/2.在 Linux 和 Mac OS X 上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/2.在 Linux 和 Mac OS X 上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.2.</b>
                        
                        2.在 Linux 和 Mac OS X 上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/3.在 Linux 和 Mac OS X 上启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/3.在 Linux 和 Mac OS X 上启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.3.</b>
                        
                        3.在 Linux 和 Mac OS X 上启动 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/4.在 Windows 上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/4.在 Windows 上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.4.</b>
                        
                        4.在 Windows 上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3.5" data-path="4.安装 Drill/3.安装 Drill 到嵌入模式/5.在 Windows 上启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/3.安装 Drill 到嵌入模式/5.在 Windows 上启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.5.</b>
                        
                        5.在 Windows 上启动 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" >
            
            <span><b>4.4.</b> 4.安装 Drill 到分布式模式</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/1.分布式模式的先决条件.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/1.分布式模式的先决条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        1.分布式模式的先决条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/2.在集群上安装 Drill.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/2.在集群上安装 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        2.在集群上安装 Drill
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="4.安装 Drill/4.安装 Drill 到分布式模式/3.在分布式模式下启动 Drill.html">
            
                
                    <a href="../../4.安装 Drill/4.安装 Drill 到分布式模式/3.在分布式模式下启动 Drill.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        3.在分布式模式下启动 Drill
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="4.安装 Drill/5.启动 Web 控制台.html">
            
                
                    <a href="../../4.安装 Drill/5.启动 Web 控制台.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        5.启动 Web 控制台
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" >
            
            <span><b>5.</b> 5.配置 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="5.配置 Drill/1.配置介绍.html">
            
                
                    <a href="../../5.配置 Drill/1.配置介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        1.配置介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="5.配置 Drill/2.配置内存.html">
            
                
                    <a href="../../5.配置 Drill/2.配置内存.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        2.配置内存
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" >
            
            <span><b>5.3.</b> 3.配置一个多租户集群</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.3.1" data-path="5.配置 Drill/3.配置一个多租户集群/1.配置一个多租户介绍.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/1.配置一个多租户介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.1.</b>
                        
                        1.配置一个多租户介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3.2" data-path="5.配置 Drill/3.配置一个多租户集群/2.配置多租户资源.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/2.配置多租户资源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.2.</b>
                        
                        2.配置多租户资源
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3.3" data-path="5.配置 Drill/3.配置一个多租户集群/3.配置 Drillbit 共享资源.html">
            
                
                    <a href="../../5.配置 Drill/3.配置一个多租户集群/3.配置 Drillbit 共享资源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.3.</b>
                        
                        3.配置 Drillbit 共享资源
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="5.配置 Drill/4.配置模拟身份.html">
            
                
                    <a href="../../5.配置 Drill/4.配置模拟身份.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        4.配置模拟身份
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="5.配置 Drill/5.配置用户身份验证.html">
            
                
                    <a href="../../5.配置 Drill/5.配置用户身份验证.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        5.配置用户身份验证
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="5.配置 Drill/6.配置 Hive 用户身份验证.html">
            
                
                    <a href="../../5.配置 Drill/6.配置 Hive 用户身份验证.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        6.配置 Hive 用户身份验证
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="5.配置 Drill/7.配置 Web 控制台和 REST API 安全.html">
            
                
                    <a href="../../5.配置 Drill/7.配置 Web 控制台和 REST API 安全.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        7.配置 Web 控制台和 REST API 安全
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" >
            
            <span><b>5.8.</b> 8.可选配置</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.8.1" data-path="5.配置 Drill/8.可选配置/1.可选配置介绍.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/1.可选配置介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.1.</b>
                        
                        1.可选配置介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.2" data-path="5.配置 Drill/8.可选配置/2.启动可选项.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/2.启动可选项.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.2.</b>
                        
                        2.启动可选项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.3" data-path="5.配置 Drill/8.可选配置/3.计划和执行可选项.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/3.计划和执行可选项.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.3.</b>
                        
                        3.计划和执行可选项
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8.4" data-path="5.配置 Drill/8.可选配置/4.持久化配置存储.html">
            
                
                    <a href="../../5.配置 Drill/8.可选配置/4.持久化配置存储.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.4.</b>
                        
                        4.持久化配置存储
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="5.配置 Drill/9.Drill 端口使用.html">
            
                
                    <a href="../../5.配置 Drill/9.Drill 端口使用.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        9.Drill 端口使用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="5.配置 Drill/10.配置 Drill 终端.html">
            
                
                    <a href="../../5.配置 Drill/10.配置 Drill 终端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        10.配置 Drill 终端
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" >
            
            <span><b>6.</b> 6.连接数据源</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="6.连接数据源/1.介绍.html">
            
                
                    <a href="../../6.连接数据源/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="6.连接数据源/2.注册存储插件.html">
            
                
                    <a href="../../6.连接数据源/2.注册存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        2.注册存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" >
            
            <span><b>6.3.</b> 3.配置存储插件</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.3.1" data-path="6.连接数据源/3.配置存储插件/1.插件基础设置.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/1.插件基础设置.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.1.</b>
                        
                        1.插件基础设置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3.2" data-path="6.连接数据源/3.配置存储插件/2.工作区间.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/2.工作区间.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.2.</b>
                        
                        2.工作区间
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3.3" data-path="6.连接数据源/3.配置存储插件/3.Drill 默认输出格式.html">
            
                
                    <a href="../../6.连接数据源/3.配置存储插件/3.Drill 默认输出格式.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.3.</b>
                        
                        3.Drill 默认输出格式
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="6.连接数据源/4.文件系统存储插件.html">
            
                
                    <a href="../../6.连接数据源/4.文件系统存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        4.文件系统存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="6.连接数据源/5.HBase 存储插件.html">
            
                
                    <a href="../../6.连接数据源/5.HBase 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        5.HBase 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="6.连接数据源/6.Hive 存储插件.html">
            
                
                    <a href="../../6.连接数据源/6.Hive 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        6.Hive 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="6.连接数据源/7.RDBMS 存储插件.html">
            
                
                    <a href="../../6.连接数据源/7.RDBMS 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        7.RDBMS 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="6.连接数据源/8.MongoDB 存储插件.html">
            
                
                    <a href="../../6.连接数据源/8.MongoDB 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        8.MongoDB 存储插件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="6.连接数据源/9.S3 存储插件.html">
            
                
                    <a href="../../6.连接数据源/9.S3 存储插件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        9.S3 存储插件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" >
            
            <span><b>7.</b> 7.ODBC 和 JDBC 接口</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="7.ODBC 和 JDBC 接口/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="7.ODBC 和 JDBC 接口/2.使用 JDBC 驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/2.使用 JDBC 驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        2.使用 JDBC 驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="7.ODBC 和 JDBC 接口/3.在 Windows 上使用 JDBC 和 SQuirreL.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/3.在 Windows 上使用 JDBC 和 SQuirreL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        3.在 Windows 上使用 JDBC 和 SQuirreL
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" >
            
            <span><b>7.4.</b> 4.安装 ODBC 驱动</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.4.1" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/1.在 Linux 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/1.在 Linux 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.1.</b>
                        
                        1.在 Linux 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.2" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/2.在 Mac OS X 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/2.在 Mac OS X 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.2.</b>
                        
                        2.在 Mac OS X 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.3" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/3.在 Windows 上安装驱动.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/3.在 Windows 上安装驱动.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.3.</b>
                        
                        3.在 Windows 上安装驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4.4" data-path="7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/4.在 Windows 上安装 TDC 文件.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/4.安装 ODBC 驱动/4.在 Windows 上安装 TDC 文件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.4.</b>
                        
                        4.在 Windows 上安装 TDC 文件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.5" >
            
            <span><b>7.5.</b> 5.配置 ODBC</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.5.1" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/1.ODBC 配置参考.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/1.ODBC 配置参考.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.1.</b>
                        
                        1.ODBC 配置参考
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.2" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/2.在 Linux 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/2.在 Linux 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.2.</b>
                        
                        2.在 Linux 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.3" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/3.在 Max OS X 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/3.在 Max OS X 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.3.</b>
                        
                        3.在 Max OS X 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.4" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/4.在 Windows 上配置 ODBC.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/4.在 Windows 上配置 ODBC.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.4.</b>
                        
                        4.在 Windows 上配置 ODBC
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5.5" data-path="7.ODBC 和 JDBC 接口/5.配置 ODBC/5.测试 ODBC 连接.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/5.配置 ODBC/5.测试 ODBC 连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.5.</b>
                        
                        5.测试 ODBC 连接
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.6" >
            
            <span><b>7.6.</b> 6.使用 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.6.1" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6.2" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/2.连接 Drill 到数据源.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/2.连接 Drill 到数据源.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.2.</b>
                        
                        2.连接 Drill 到数据源
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6.3" data-path="7.ODBC 和 JDBC 接口/6.使用 Drill/3.浏览数据和定义视图.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/6.使用 Drill/3.浏览数据和定义视图.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.3.</b>
                        
                        3.浏览数据和定义视图
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7.7" >
            
            <span><b>7.7.</b> 7.用 BI 工具连接 Drill</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.7.1" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/1.介绍.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/1.介绍.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.1.</b>
                        
                        1.介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.2" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/2.Tableau 示例.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/2.Tableau 示例.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.2.</b>
                        
                        2.使用 JDBC 驱动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.3" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/3.使用 MicroStrategy 分析.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/3.使用 MicroStrategy 分析.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.3.</b>
                        
                        3.在 Windows 上使用 JDBC 和 SQuirreL
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.4" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/4.使用 Tibco Spotfire 客户端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/4.使用 Tibco Spotfire 客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.4.</b>
                        
                        4.使用 Tibco Spotfire 客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.5" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/5.使用 Qlik Sense.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/5.使用 Qlik Sense.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.5.</b>
                        
                        5.使用 Qlik Sense
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.6" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/6.使用 Tableau 9 客户端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/6.使用 Tableau 9 客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.6.</b>
                        
                        6.使用 Tableau 9 客户端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.7" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/7.使用 Tableau 9 服务端.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/7.使用 Tableau 9 服务端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.7.</b>
                        
                        7.使用 Tableau 9 服务端
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.7.8" data-path="7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/8.配置 JReport.html">
            
                
                    <a href="../../7.ODBC 和 JDBC 接口/7.用 BI 工具连接 Drill/8.配置 JReport.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.7.8.</b>
                        
                        8.配置 JReport
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本书使用 GitBook 发布
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >Apache Drill</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x8BFE;&#x7A0B;3&#xFF1A;&#x67E5;&#x8BE2;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x8BFE;&#x7A0B;3&#xFF1A;&#x67E5;&#x8BE2;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;</h1>
<h2 id="&#x76EE;&#x6807;">&#x76EE;&#x6807;</h2>
<p>&#x672C;&#x8282;&#x8BFE;&#x7684;&#x91CD;&#x70B9;&#x662F;&#x5173;&#x4E8E;&#x81EA;&#x5B9A;&#x4E49;&#x6570;&#x636E;&#x548C;&#x590D;&#x6742;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x7684;&#x7EC3;&#x4E60;&#x548C;&#x8FD0;&#x7B97;&#x7B26;&#x7684;&#x67E5;&#x8BE2;&#x3002;Drill &#x63D0;&#x4F9B;&#x4E86;&#x76F4;&#x89C2;&#x7684; SQL &#x6269;&#x5C55;&#x5230;&#x8FD9;&#x6837;&#x7684;&#x6570;&#x636E;&#x5F53;&#x4E2D;&#xFF0C;&#x5E76;&#x63D0;&#x9AD8;&#x9AD8;&#x6027;&#x80FD;&#x7684;&#x67E5;&#x8BE2;&#x548C;&#x590D;&#x6742;&#x6784;&#x5EFA;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<h2 id="&#x67E5;&#x8BE2;">&#x67E5;&#x8BE2;</h2>
<p>&#x73B0;&#x5728;&#x4F60;&#x53EF;&#x4EE5;&#x8FD0;&#x884C; SQL &#x8BED;&#x53E5;&#x53BB;&#x67E5;&#x8BE2;&#x4E0D;&#x540C;&#x7684;&#x8868;&#x548C;&#x6587;&#x4EF6;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x5C1D;&#x8BD5;&#x53BB;&#x67E5;&#x8BE2;&#x4E00;&#x4E9B;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;</p>
<ul>
<li>&#x8FDB;&#x5165;&#x5230;&#x76EE;&#x5F55;&#x6216;&#x5B50;&#x76EE;&#x5F55;&#x4E2D;&#x7684;&#x6587;&#x4EF6;&#xFF0C;&#x4F7F;&#x7528;&#x5355;&#x6311; <code>SELECT</code> &#x8BED;&#x53E5;&#x3002;</li>
<li>&#x5C55;&#x793A;&#x7B80;&#x5355;&#x7684;&#x65B9;&#x5F0F;&#x53BB;&#x8BBF;&#x95EE; JSON &#x6587;&#x4EF6;&#x4E2D;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x3002;</li>
<li>&#x5C55;&#x793A; <code>repeated_count</code> &#x51FD;&#x6570;&#x53BB;&#x805A;&#x5408;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x503C;&#x3002;</li>
</ul>
<h2 id="&#x67E5;&#x8BE2;&#x5206;&#x533A;&#x76EE;&#x5F55;">&#x67E5;&#x8BE2;&#x5206;&#x533A;&#x76EE;&#x5F55;</h2>
<p>&#x4F60;&#x53EF;&#x4EE5;&#x5728; Drill &#x4E2D;&#x4F7F;&#x7528;&#x7279;&#x5B9A;&#x7684;&#x53D8;&#x91CF;&#xFF0C;&#x6307;&#x5411;&#x4F60;&#x5DE5;&#x4F5C;&#x8DEF;&#x5F84;&#x7684;&#x5B50;&#x76EE;&#x5F55;&#xFF1A;</p>
<ul>
<li>dir0</li>
<li>dir1</li>
<li>...</li>
</ul>
<p>&#x8BF7;&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x4E9B;&#x53D8;&#x91CF;&#x662F;&#x57FA;&#x4E8E;&#x6587;&#x4EF6;&#x7CFB;&#x7EDF;&#x7684;&#x5206;&#x533A;&#x52A8;&#x6001;&#x786E;&#x5B9A;&#x7684;&#x3002;&#x5728;&#x6CA1;&#x6709;&#x524D;&#x5B9A;&#x4E49;&#x7684;&#x5206;&#x533A;&#x4E0A;&#x5B58;&#x5728;&#x3002;&#x4E0B;&#x9762;&#x662F;&#x4E00;&#x4E2A;&#x53EF;&#x89C6;&#x5316;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x5C55;&#x793A;&#x8FD9;&#x4E2A;&#x6D41;&#x7A0B;&#x662F;&#x5982;&#x4F55;&#x5DE5;&#x4F5C;&#x7684;&#xFF1A;</p>
<p><img src="../../res/example_query.png" alt="example_query.png"></p>
<h3 id="&#x5207;&#x6362;&#x5230;-dfslog-&#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;">&#x5207;&#x6362;&#x5230; dfs.log &#x5DE5;&#x4F5C;&#x533A;&#x95F4;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use dfs.logs;
+-------+---------------------------------------+
|  ok   |                summary                |
+-------+---------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [dfs.logs]  |
+-------+---------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x67E5;&#x8BE2;&#x6307;&#x5B9A;&#x5E74;&#x6570;&#x636E;&#xFF1A;">&#x67E5;&#x8BE2;&#x6307;&#x5B9A;&#x5E74;&#x6570;&#x636E;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select * from logs <span class="hljs-built_in">where</span> dir0=<span class="hljs-string">&apos;2013&apos;</span> <span class="hljs-built_in">limit</span> <span class="hljs-number">10</span>;
+-------+-------+-----------+-------------+-----------+----------+---------+--------+----------+-----------+----------+-------------+
| dir0  | dir1  | trans_id  |    date     |   time    | cust_id  | device  | state  | camp_id  | keywords  | prod_id  | purch_flag  |
+-------+-------+-----------+-------------+-----------+----------+---------+--------+----------+-----------+----------+-------------+
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12104</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">29</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">09</span>:<span class="hljs-number">34</span>:<span class="hljs-number">37</span>  | <span class="hljs-number">962</span>      | IOS5    | ma     | <span class="hljs-number">3</span>        | milhouse  | <span class="hljs-number">17</span>       | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12132</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">23</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">01</span>:<span class="hljs-number">11</span>:<span class="hljs-number">25</span>  | <span class="hljs-number">4</span>        | IOS7    | mi     | <span class="hljs-number">11</span>       | hi        | <span class="hljs-number">439</span>      | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12177</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">14</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">13</span>:<span class="hljs-number">48</span>:<span class="hljs-number">50</span>  | <span class="hljs-number">23</span>       | AOS4.<span class="hljs-number">2</span>  | il     | <span class="hljs-number">14</span>       | give      | <span class="hljs-number">382</span>      | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12180</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">03</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">20</span>:<span class="hljs-number">48</span>:<span class="hljs-number">45</span>  | <span class="hljs-number">1509</span>     | IOS7    | ca     | <span class="hljs-number">0</span>        | i<span class="hljs-string">&apos;m       | 340      | false       |
| 2013  | 8     | 12187     | 08/16/2013  | 10:28:07  | 0        | IOS5    | ny     | 16       | clicking  | 11       | false       |
| 2013  | 8     | 12190     | 08/10/2013  | 14:16:50  | 9        | IOS5    | va     | 3        | a         | 495      | false       |
| 2013  | 8     | 12200     | 08/02/2013  | 20:54:38  | 42219    | IOS5    | ia     | 0        | what&apos;</span>s    | <span class="hljs-number">346</span>      | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12210</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">05</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">20</span>:<span class="hljs-number">12</span>:<span class="hljs-number">24</span>  | <span class="hljs-number">8073</span>     | IOS5    | sc     | <span class="hljs-number">5</span>        | <span class="hljs-keyword">if</span>        | <span class="hljs-number">33</span>       | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12235</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">28</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">07</span>:<span class="hljs-number">49</span>:<span class="hljs-number">45</span>  | <span class="hljs-number">595</span>      | IOS5    | tx     | <span class="hljs-number">2</span>        | that      | <span class="hljs-number">51</span>       | <span class="hljs-literal">false</span>       |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>     | <span class="hljs-number">12239</span>     | <span class="hljs-number">08</span>/<span class="hljs-number">13</span>/<span class="hljs-number">2013</span>  | <span class="hljs-number">03</span>:<span class="hljs-number">24</span>:<span class="hljs-number">31</span>  | <span class="hljs-number">2</span>        | IOS5    | or     | <span class="hljs-number">6</span>        | haw-haw   | <span class="hljs-number">40</span>       | <span class="hljs-literal">false</span>       |
+-------+-------+-----------+-------------+-----------+----------+---------+--------+----------+-----------+----------+-------------+
<span class="hljs-number">10</span> rows selected
</code></pre>
<p>&#x8BE5;&#x67E5;&#x8BE2;&#x5728;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x662F;&#x5B50;&#x76EE;&#x5F55;&#x9650;&#x5236;&#x5728; 2013&#x3002;&#x53D8;&#x91CF;&#x662F;&#x4ECE; dir0 &#x6307;&#x5411;&#x4E0B;&#x4E00;&#x7EA7;&#x7684; dir1&#xFF0C;&#x7B49;&#x7B49;&#x3002;&#x56E0;&#x6B64;&#xFF0C;&#x6B64;&#x67E5;&#x8BE2;&#x7684;&#x8FD4;&#x56DE;&#x7ED3;&#x679C;&#x662F;&#x8FD4;&#x56DE; 2013 &#x5E74;&#x7684; 10 &#x6761;&#x8BB0;&#x5F55;&#x3002;</p>
<h3 id="&#x5728;&#x67E5;&#x8BE2;&#x4E2D;&#x4F7F;&#x7528;&#x591A;&#x91CD;&#x5224;&#x65AD;&#x67E5;&#x8BE2;">&#x5728;&#x67E5;&#x8BE2;&#x4E2D;&#x4F7F;&#x7528;&#x591A;&#x91CD;&#x5224;&#x65AD;&#x67E5;&#x8BE2;</h3>
<p>&#x6B64;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x901A;&#x8FC7; 2013 &#x5E74;&#x516B;&#x6708;&#x8D2D;&#x4E70; iOS5 &#x8BBE;&#x5907;&#x7684;&#x5BA2;&#x6237; ID &#x5217;&#x8868;&#xFF1A;</p>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select dir0 as yr, dir1 as mth, cust_id from logs
<span class="hljs-built_in">where</span> dir0=<span class="hljs-string">&apos;2013&apos;</span> and dir1=<span class="hljs-string">&apos;8&apos;</span> and device=<span class="hljs-string">&apos;IOS5&apos;</span> and purch_flag=<span class="hljs-string">&apos;true&apos;</span>
order by `date`;
+-------+------+----------+
|  yr   | mth  | cust_id  |
+-------+------+----------+
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>    | <span class="hljs-number">4</span>        |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>    | <span class="hljs-number">521</span>      |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>    | <span class="hljs-number">1</span>        |
| <span class="hljs-number">2013</span>  | <span class="hljs-number">8</span>    | <span class="hljs-number">2</span>        |

...
</code></pre>
<h3 id="&#x7EDF;&#x8BA1;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x6BCF;&#x6708;">&#x7EDF;&#x8BA1;&#x6BCF;&#x4E2A;&#x7528;&#x6237;&#x7684;&#x6BCF;&#x6708;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select cust_id, dir1 month_no, count(*) month_count from logs
<span class="hljs-built_in">where</span> dir0=<span class="hljs-number">2014</span> group by cust_id, dir1 order by cust_id, month_no <span class="hljs-built_in">limit</span> <span class="hljs-number">10</span>;
+----------+-----------+--------------+
| cust_id  | month_no  | month_count  |
+----------+-----------+--------------+
| <span class="hljs-number">0</span>        | <span class="hljs-number">1</span>         | <span class="hljs-number">143</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">2</span>         | <span class="hljs-number">118</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">3</span>         | <span class="hljs-number">117</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">4</span>         | <span class="hljs-number">115</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">5</span>         | <span class="hljs-number">137</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">6</span>         | <span class="hljs-number">117</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">7</span>         | <span class="hljs-number">142</span>          |
| <span class="hljs-number">0</span>        | <span class="hljs-number">8</span>         | <span class="hljs-number">19</span>           |
| <span class="hljs-number">1</span>        | <span class="hljs-number">1</span>         | <span class="hljs-number">66</span>           |
| <span class="hljs-number">1</span>        | <span class="hljs-number">2</span>         | <span class="hljs-number">59</span>           |
+----------+-----------+--------------+
<span class="hljs-number">10</span> rows selected
</code></pre>
<p>&#x8BE5;&#x5206;&#x7EC4;&#x67E5;&#x8BE2;&#x4F7F;&#x7528;&#x4E86;&#x805A;&#x5408;&#x51FD;&#x6570;&#xFF0C;&#x5206;&#x7EC4;&#x6761;&#x4EF6;&#x7531;&#x5BA2;&#x6237; ID &#x548C;&#x6708;&#x4EFD;&#x7EC4;&#x6210;&#xFF0C;&#x7EA6;&#x675F;&#x6761;&#x4EF6;&#x4E3A;&#x5E74;&#x4EFD;&#xFF1A;2014&#x3002;</p>
<h2 id="&#x67E5;&#x8BE2;&#x590D;&#x6742;&#x6570;&#x636E;">&#x67E5;&#x8BE2;&#x590D;&#x6742;&#x6570;&#x636E;</h2>
<p>Drill &#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E9B;&#x4E13;&#x95E8;&#x7684;&#x8FD0;&#x7B97;&#x7B26;&#x548C;&#x51FD;&#x6570;&#xFF0C;&#x80FD;&#x591F;&#x8BA9;&#x4F60;&#x4F7F;&#x7528;&#x5D4C;&#x5957;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x5206;&#x6790;&#x3002;&#x5982;&#x679C;&#x4F60;&#x719F;&#x6089; JavaScript &#x8BED;&#x6CD5;&#xFF0C;&#x4F60;&#x5C06;&#x4F1A;&#x77E5;&#x9053;&#x5982;&#x4F55;&#x53BB;&#x6269;&#x5C55;&#x8BE5;&#x5DE5;&#x4F5C;&#x3002;</p>
<h3 id="&#x5207;&#x6362;&#x5230;dfsclicks&#xFF1A;">&#x5207;&#x6362;&#x5230;dfs.clicks&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use dfs.clicks;
+-------+-----------------------------------------+
|  ok   |                 summary                 |
+-------+-----------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [dfs.clicks]  |
+-------+-----------------------------------------+
<span class="hljs-number">1</span> row selected
</code></pre>
<h3 id="&#x7814;&#x7A76;&#x70B9;&#x51FB;&#x6570;&#x636E;">&#x7814;&#x7A76;&#x70B9;&#x51FB;&#x6570;&#x636E;</h3>
<p>&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;user_info &#x548C; trans_info &#x5217;&#x5305;&#x542B;&#x5D4C;&#x5957;&#x6570;&#x636E;&#xFF1A;&#x6570;&#x7EC4;&#x4E2D;&#x5305;&#x542B;&#x6570;&#x7EC4;&#x3002;&#x4E0B;&#x9762;&#x5C55;&#x793A;&#x5982;&#x4F55;&#x67E5;&#x8BE2;&#x590D;&#x6742;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select * from `clicks/clicks.json` <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+-----------+-------------+-----------+---------------------------------------------------+---------------------------------------------------------------------------+
| trans_id  |    date     |   time    |                     user_info                     |                                trans_info                                 |
+-----------+-------------+-----------+---------------------------------------------------+---------------------------------------------------------------------------+
| <span class="hljs-number">31920</span>     | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">26</span>  | <span class="hljs-number">12</span>:<span class="hljs-number">17</span>:<span class="hljs-number">12</span>  | {<span class="hljs-string">&quot;cust_id&quot;</span>:<span class="hljs-number">22526</span>,<span class="hljs-string">&quot;device&quot;</span>:<span class="hljs-string">&quot;IOS5&quot;</span>,<span class="hljs-string">&quot;state&quot;</span>:<span class="hljs-string">&quot;il&quot;</span>}    | {<span class="hljs-string">&quot;prod_id&quot;</span>:[<span class="hljs-number">174</span>,<span class="hljs-number">2</span>],<span class="hljs-string">&quot;purch_flag&quot;</span>:<span class="hljs-string">&quot;false&quot;</span>}                                  |
| <span class="hljs-number">31026</span>     | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">20</span>  | <span class="hljs-number">13</span>:<span class="hljs-number">50</span>:<span class="hljs-number">29</span>  | {<span class="hljs-string">&quot;cust_id&quot;</span>:<span class="hljs-number">16368</span>,<span class="hljs-string">&quot;device&quot;</span>:<span class="hljs-string">&quot;AOS4.2&quot;</span>,<span class="hljs-string">&quot;state&quot;</span>:<span class="hljs-string">&quot;nc&quot;</span>}  | {<span class="hljs-string">&quot;prod_id&quot;</span>:[],<span class="hljs-string">&quot;purch_flag&quot;</span>:<span class="hljs-string">&quot;false&quot;</span>}                                       |
| <span class="hljs-number">33848</span>     | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">10</span>  | <span class="hljs-number">04</span>:<span class="hljs-number">44</span>:<span class="hljs-number">42</span>  | {<span class="hljs-string">&quot;cust_id&quot;</span>:<span class="hljs-number">21449</span>,<span class="hljs-string">&quot;device&quot;</span>:<span class="hljs-string">&quot;IOS6&quot;</span>,<span class="hljs-string">&quot;state&quot;</span>:<span class="hljs-string">&quot;oh&quot;</span>}    | {<span class="hljs-string">&quot;prod_id&quot;</span>:[<span class="hljs-number">582</span>],<span class="hljs-string">&quot;purch_flag&quot;</span>:<span class="hljs-string">&quot;false&quot;</span>}                                    |
| <span class="hljs-number">32383</span>     | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">18</span>  | <span class="hljs-number">06</span>:<span class="hljs-number">27</span>:<span class="hljs-number">47</span>  | {<span class="hljs-string">&quot;cust_id&quot;</span>:<span class="hljs-number">20323</span>,<span class="hljs-string">&quot;device&quot;</span>:<span class="hljs-string">&quot;IOS5&quot;</span>,<span class="hljs-string">&quot;state&quot;</span>:<span class="hljs-string">&quot;oh&quot;</span>}    | {<span class="hljs-string">&quot;prod_id&quot;</span>:[<span class="hljs-number">710</span>,<span class="hljs-number">47</span>],<span class="hljs-string">&quot;purch_flag&quot;</span>:<span class="hljs-string">&quot;false&quot;</span>}                                 |
| <span class="hljs-number">32359</span>     | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">19</span>  | <span class="hljs-number">23</span>:<span class="hljs-number">13</span>:<span class="hljs-number">25</span>  | {<span class="hljs-string">&quot;cust_id&quot;</span>:<span class="hljs-number">15360</span>,<span class="hljs-string">&quot;device&quot;</span>:<span class="hljs-string">&quot;IOS5&quot;</span>,<span class="hljs-string">&quot;state&quot;</span>:<span class="hljs-string">&quot;ca&quot;</span>}    | {<span class="hljs-string">&quot;prod_id&quot;</span>:[<span class="hljs-number">0</span>,<span class="hljs-number">8</span>,<span class="hljs-number">170</span>,<span class="hljs-number">173</span>,<span class="hljs-number">1</span>,<span class="hljs-number">124</span>,<span class="hljs-number">46</span>,<span class="hljs-number">764</span>,<span class="hljs-number">30</span>,<span class="hljs-number">711</span>,<span class="hljs-number">0</span>,<span class="hljs-number">3</span>,<span class="hljs-number">25</span>],<span class="hljs-string">&quot;purch_flag&quot;</span>:<span class="hljs-string">&quot;true&quot;</span>}  |
+-----------+-------------+-----------+---------------------------------------------------+---------------------------------------------------------------------------+
<span class="hljs-number">5</span> rows selected
</code></pre>
<h3 id="&#x5206;&#x89E3;-userinfo-&#x5217;&#xFF1A;">&#x5206;&#x89E3; user_info &#x5217;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.user_info.cust_id as custid, t.user_info.device as device,
t.user_info.state as state
from `clicks/clicks.json` t <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+---------+---------+--------+
| custid  | device  | state  |
+---------+---------+--------+
| <span class="hljs-number">22526</span>   | IOS5    | il     |
| <span class="hljs-number">16368</span>   | AOS4.<span class="hljs-number">2</span>  | nc     |
| <span class="hljs-number">21449</span>   | IOS6    | oh     |
| <span class="hljs-number">20323</span>   | IOS5    | oh     |
| <span class="hljs-number">15360</span>   | IOS5    | ca     |
+---------+---------+--------+
<span class="hljs-number">5</span> rows selected (<span class="hljs-number">0.171</span> seconds)
</code></pre>
<p>&#x8BE5;&#x67E5;&#x8BE2;&#x4F7F;&#x7528;&#x7B80;&#x5355;&#x7684;<code>&#x8868;.&#x5217;.&#x5217;</code> &#x8FD9;&#x6837;&#x7684;&#x65B9;&#x5F0F;&#x53BB;&#x5206;&#x89E3;&#x5D4C;&#x5957;&#x6570;&#x636E;&#x3002;&#x5982;&#x4E0B;&#x6240;&#x793A;&#xFF1A;</p>
<pre><code>t.user_info.cust_id
</code></pre><p>&#x5728;&#x67E5;&#x8BE2;&#x4E2D;&#xFF0C;&#x8FD9;&#x91CC;&#x7684; t &#x6307;&#x7684;&#x662F;&#x8868;&#x7684;&#x522B;&#x540D;&#xFF0C;<code>user_info</code> &#x662F;&#x6700;&#x5916;&#x5C42;&#x7684;&#x5217;&#xFF0C;&#x5E76;&#x4E14; <code>cust_id</code> &#x662F;&#x4E00;&#x4E2A;&#x5D4C;&#x5957;&#x5217;&#x3002;</p>
<p>&#x8868;&#x522B;&#x540D;&#x662F;&#x5FC5;&#x9700;&#x7684;&#xFF1B;&#x5426;&#x5219;&#x5217;&#x540D;&#xFF0C;&#x4F8B;&#x5982; <code>user_info</code> &#x4F1A;&#x5728; SQL &#x4E2D;&#x89E3;&#x6790;&#x7684;&#x65F6;&#x5019;&#x88AB;&#x5F53;&#x4F5C;&#x6210;&#x8868;&#x540D;&#x3002;</p>
<h3 id="&#x89E3;&#x6790;-transinfo-&#x5217;&#xFF1A;">&#x89E3;&#x6790; trans_info &#x5217;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.trans_info.prod_id as prodid, t.trans_info.purch_flag as
purchased
from `clicks/clicks.json` t <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+-------------------------------------------+------------+
|                  prodid                   | purchased  |
+-------------------------------------------+------------+
| [<span class="hljs-number">174</span>,<span class="hljs-number">2</span>]                                   | <span class="hljs-literal">false</span>      |
| []                                        | <span class="hljs-literal">false</span>      |
| [<span class="hljs-number">582</span>]                                     | <span class="hljs-literal">false</span>      |
| [<span class="hljs-number">710</span>,<span class="hljs-number">47</span>]                                  | <span class="hljs-literal">false</span>      |
| [<span class="hljs-number">0</span>,<span class="hljs-number">8</span>,<span class="hljs-number">170</span>,<span class="hljs-number">173</span>,<span class="hljs-number">1</span>,<span class="hljs-number">124</span>,<span class="hljs-number">46</span>,<span class="hljs-number">764</span>,<span class="hljs-number">30</span>,<span class="hljs-number">711</span>,<span class="hljs-number">0</span>,<span class="hljs-number">3</span>,<span class="hljs-number">25</span>]  | <span class="hljs-literal">true</span>       |
+-------------------------------------------+------------+
<span class="hljs-number">5</span> rows selected
</code></pre>
<p>&#x6CE8;&#x610F;&#xFF0C;&#x8FD9;&#x4E2A;&#x7ED3;&#x679C;&#x8868;&#x660E;&#xFF0C;prod_id &#x5217;&#x5305;&#x542B;&#x4E00;&#x4E2A; ID &#x6570;&#x7EC4;&#xFF08;&#x4E00;&#x4E2A;&#x6216;&#x591A;&#x4E2A;&#x4EA7;&#x54C1; ID&#x4E8E;&#x6BCF;&#x884C;&#xFF0C;&#x7528;&#x9017;&#x53F7;&#x5206;&#x5272;&#xFF09;&#x3002;&#x4E0B;&#x4E00;&#x6B65;&#x5C06;&#x4E3A;&#x5927;&#x5BB6;&#x6F14;&#x793A;&#x5982;&#x4F55;&#x53BB;&#x8BBF;&#x95EE;&#x8FD9;&#x79CD;&#x6570;&#x636E;&#x3002;</p>
<h2 id="&#x6570;&#x7EC4;&#x67E5;&#x8BE2;">&#x6570;&#x7EC4;&#x67E5;&#x8BE2;</h2>
<p>&#x73B0;&#x5728;&#x4F7F;&#x7528; [n] &#x7B26;&#x53F7;&#xFF0C;&#x5176;&#x4E2D; n &#x662F;&#x5728;&#x6570;&#x7EC4;&#x4E2D;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x4ECE; 0&#xFF08;&#x4E0D;&#x662F; 1&#xFF09;&#x8868;&#x793A;&#x7B2C;&#x4E00;&#x4E2A;&#x503C;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x7B26;&#x53F7;&#x5199;&#x4E00;&#x4E9B;&#x6709;&#x8DA3;&#x7684;&#x67E5;&#x8BE2;&#xFF0C;&#x53BB;&#x67E5;&#x8BE2;&#x4E00;&#x4E9B;&#x5D4C;&#x5957;&#x6570;&#x7EC4;&#x6570;&#x636E;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;</p>
<pre><code>trans_info.prod_id[0]
</code></pre><p>&#x83B7;&#x53D6;&#x6307;&#x5B9A;&#x5D4C;&#x5957;&#x6570;&#x636E;&#x4E2D;&#x7684;&#x503C;&#xFF0C;&#x5728;&#x503C;&#x5B58;&#x5728;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x83B7;&#x53D6;&#x7B2C; 21 &#x4E2A;&#x503C;&#xFF1A;</p>
<pre><code>trans_info.prod_id[20]
</code></pre><h3 id="&#x83B7;&#x53D6;&#x7B2C;&#x4E00;&#x4E2A;&#x4EA7;&#x54C1;&#x7684;&#x503C;&#xFF1A;">&#x83B7;&#x53D6;&#x7B2C;&#x4E00;&#x4E2A;&#x4EA7;&#x54C1;&#x7684;&#x503C;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.trans_id, t.trans_info.prod_id[<span class="hljs-number">0</span>] from `clicks/clicks.json` t <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+------------+------------+
|  trans_id  |   EXPR<span class="hljs-variable">$1</span>   |
+------------+------------+
| <span class="hljs-number">31920</span>      | <span class="hljs-number">174</span>        |
| <span class="hljs-number">31026</span>      | null       |
| <span class="hljs-number">33848</span>      | <span class="hljs-number">582</span>        |
| <span class="hljs-number">32383</span>      | <span class="hljs-number">710</span>        |
| <span class="hljs-number">32359</span>      | <span class="hljs-number">0</span>          |
+------------+------------+
<span class="hljs-number">5</span> rows selected
</code></pre>
<h3 id="&#x67E5;&#x8BE2;&#x7684;&#x8BB0;&#x5F55;&#x5F53;&#x4E2D;&#x81F3;&#x5C11;&#x5305;&#x542B;-21-&#x6761;&#x8BB0;&#x5F55;">&#x67E5;&#x8BE2;&#x7684;&#x8BB0;&#x5F55;&#x5F53;&#x4E2D;&#x81F3;&#x5C11;&#x5305;&#x542B; 21 &#x6761;&#x8BB0;&#x5F55;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.trans_id, t.trans_info.prod_id[<span class="hljs-number">20</span>]
from `clicks/clicks.json` t
<span class="hljs-built_in">where</span> t.trans_info.prod_id[<span class="hljs-number">20</span>] is not null
order by trans_id <span class="hljs-built_in">limit</span> <span class="hljs-number">5</span>;
+------------+------------+
|  trans_id  |   EXPR<span class="hljs-variable">$1</span>   |
+------------+------------+
| <span class="hljs-number">10328</span>      | <span class="hljs-number">0</span>          |
| <span class="hljs-number">10380</span>      | <span class="hljs-number">23</span>         |
| <span class="hljs-number">10701</span>      | <span class="hljs-number">1</span>          |
| <span class="hljs-number">11100</span>      | <span class="hljs-number">0</span>          |
| <span class="hljs-number">11219</span>      | <span class="hljs-number">46</span>         |
+------------+------------+
<span class="hljs-number">5</span> rows selected
</code></pre>
<p>&#x8BE5;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A; transaction &#x7684; ID &#x548C; product &#x7684; ID &#x7684;&#x8BB0;&#x5F55;&#xFF0C;&#x5176;&#x4E2D; product &#x7684; ID &#x4E0D;&#x4E3A; null&#xFF0C;&#x5728;&#x6570;&#x7EC4;&#x7684;&#x4E0B;&#x6807;&#x4E3A; 21 &#x7684;&#x7D22;&#x5F15;&#x5904;&#x5F00;&#x59CB;&#x3002;</p>
<h3 id="&#x8FD4;&#x56DE;&#x70B9;&#x51FB;&#x5546;&#x54C1;&#x533A;&#x95F4;">&#x8FD4;&#x56DE;&#x70B9;&#x51FB;&#x5546;&#x54C1;&#x533A;&#x95F4;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select * from (select t.trans_id, t.trans_info.prod_id[<span class="hljs-number">0</span>] as prodid,
t.trans_info.purch_flag as purchased
from `clicks/clicks.json` t) sq
<span class="hljs-built_in">where</span> sq.prodid between <span class="hljs-number">700</span> and <span class="hljs-number">750</span> and sq.purchased=<span class="hljs-string">&apos;true&apos;</span>
order by sq.prodid;
+------------+------------+------------+
|  trans_id  |   prodid   | purchased  |
+------------+------------+------------+
| <span class="hljs-number">21886</span>      | <span class="hljs-number">704</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">20674</span>      | <span class="hljs-number">708</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">22158</span>      | <span class="hljs-number">709</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">34089</span>      | <span class="hljs-number">714</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">22545</span>      | <span class="hljs-number">714</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">37500</span>      | <span class="hljs-number">717</span>        | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">36595</span>      | <span class="hljs-number">718</span>        | <span class="hljs-literal">true</span>       |
...
</code></pre>
<p>&#x6B64;&#x67E5;&#x8BE2;&#x662F;&#x6309;&#x7167;&#x5546;&#x54C1;&#x7684; ID &#x8FDB;&#x884C;&#x6392;&#x5E8F;&#x7684;&#x3002;</p>
<h2 id="&#x64CD;&#x4F5C;&#x6570;&#x7EC4;">&#x64CD;&#x4F5C;&#x6570;&#x7EC4;</h2>
<h3 id="&#x5728;&#x6BCF;&#x4E2A;-session-&#x4E2D;&#xFF0C;&#x6392;&#x540D;&#x6210;&#x529F;&#x7684;&#x70B9;&#x51FB;&#x5207;&#x6362;&#x548C;&#x7EDF;&#x8BA1;&#x5546;&#x54C1;&#x7684;&#x641C;&#x7D22;&#xFF1A;">&#x5728;&#x6BCF;&#x4E2A; session &#x4E2D;&#xFF0C;&#x6392;&#x540D;&#x6210;&#x529F;&#x7684;&#x70B9;&#x51FB;&#x5207;&#x6362;&#x548C;&#x7EDF;&#x8BA1;&#x5546;&#x54C1;&#x7684;&#x641C;&#x7D22;&#xFF1A;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select t.trans_id, t.`date` as session_date, t.user_info.cust_id as
cust_id, t.user_info.device as device, repeated_count(t.trans_info.prod_id) as
prod_count, t.trans_info.purch_flag as purch_flag
from `clicks/clicks.json` t
<span class="hljs-built_in">where</span> t.trans_info.purch_flag = <span class="hljs-string">&apos;true&apos;</span> order by prod_count desc;
+------------+--------------+------------+------------+------------+------------+
|  trans_id  | session_date |  cust_id   |   device   | prod_count | purch_flag |
+------------+--------------+------------+------------+------------+------------+
| <span class="hljs-number">37426</span>      | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">06</span>   | <span class="hljs-number">18709</span>      | IOS5       | <span class="hljs-number">34</span>         | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">31589</span>      | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">16</span>   | <span class="hljs-number">18576</span>      | IOS6       | <span class="hljs-number">31</span>         | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">11600</span>      | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">07</span>   | <span class="hljs-number">4260</span>       | AOS4.<span class="hljs-number">2</span>     | <span class="hljs-number">28</span>         | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">35074</span>      | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">03</span>   | <span class="hljs-number">16697</span>      | AOS4.<span class="hljs-number">3</span>     | <span class="hljs-number">27</span>         | <span class="hljs-literal">true</span>       |
| <span class="hljs-number">17192</span>      | <span class="hljs-number">2014</span>-<span class="hljs-number">04</span>-<span class="hljs-number">22</span>   | <span class="hljs-number">2501</span>       | AOS4.<span class="hljs-number">2</span>     | <span class="hljs-number">26</span>         | <span class="hljs-literal">true</span>       |
...
</code></pre>
<p>&#x8BE5;&#x67E5;&#x8BE2;&#x4F7F;&#x7528;&#x4E86;&#x4E00;&#x4E2A; SQL &#x7684;&#x6269;&#x5C55;&#x529F;&#x80FD;&#xFF0C;repeated_count &#x51FD;&#x6570;&#xFF0C;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x6570;&#x7EC4;&#x7684;&#x805A;&#x5408;&#x7EDF;&#x8BA1;&#x3002;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x8D2D;&#x4E70;&#x7684;&#x6BCF;&#x4E00;&#x4E2A;&#x4F1A;&#x8BDD;&#x4E2D;&#x641C;&#x7D22;&#x7684;&#x4EA7;&#x54C1;&#x7684;&#x6570;&#x91CF;&#xFF0C;&#x5E76;&#x4F7F;&#x7528;&#x964D;&#x5E8F;&#x529F;&#x80FD;&#xFF0C;&#x8FDB;&#x884C;&#x6392;&#x5217;&#x8BA1;&#x6570;&#x3002;&#x4EC5;&#x4EC5;&#x9488;&#x5BF9;&#x8D2D;&#x4E70;&#x7684;&#x70B9;&#x51FB;&#x6570;&#x7EDF;&#x8BA1;&#x3002;</p>
<h2 id="&#x5B58;&#x50A8;&#x7ED3;&#x679C;&#x96C6;&#x5230;&#x8868;&#x4E2D;&#xFF0C;&#x4EE5;&#x4FBF;&#x590D;&#x7528;&#x548C;&#x5206;&#x6790;">&#x5B58;&#x50A8;&#x7ED3;&#x679C;&#x96C6;&#x5230;&#x8868;&#x4E2D;&#xFF0C;&#x4EE5;&#x4FBF;&#x590D;&#x7528;&#x548C;&#x5206;&#x6790;</h2>
<p>&#x4E3A;&#x4E86;&#x4FBF;&#x4E8E;&#x5728;&#x8BE5;&#x7ED3;&#x679C;&#x96C6;&#x4E0A;&#x8FDB;&#x884C;&#x5206;&#x6790;&#xFF0C;&#x53EF;&#x4EE5;&#x65B9;&#x4FBF;&#x5FEB;&#x6377;&#x7684;&#x4ECE;&#x67E5;&#x8BE2;&#x7ED3;&#x679C;&#x4E2D;&#x521B;&#x5EFA;&#x4E00;&#x4E2A; Drill &#x8868;&#x3002;</p>
<h3 id="&#x7EE7;&#x7EED;&#x4F7F;&#x7528;-dfsclicks-&#x5DE5;&#x4F5C;&#x533A;&#x95F4;">&#x7EE7;&#x7EED;&#x4F7F;&#x7528; dfs.clicks &#x5DE5;&#x4F5C;&#x533A;&#x95F4;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; use dfs.clicks;
+-------+-----------------------------------------+
|  ok   |                 summary                 |
+-------+-----------------------------------------+
| <span class="hljs-literal">true</span>  | Default schema changed to [dfs.clicks]  |
+-------+-----------------------------------------+
<span class="hljs-number">1</span> row selected (<span class="hljs-number">1.61</span> seconds)
</code></pre>
<h3 id="&#x8FD4;&#x56DE;&#x5546;&#x54C1;&#x641C;&#x7D22;&#x7ED3;&#x679C;">&#x8FD4;&#x56DE;&#x5546;&#x54C1;&#x641C;&#x7D22;&#x7ED3;&#x679C;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select o.cust_id, o.order_total, t.trans_info.prod_id[<span class="hljs-number">0</span>] as prod_id
from
hive.orders as o
join `clicks/clicks.json` t
on o.cust_id=t.user_info.cust_id
<span class="hljs-built_in">where</span> o.order_total &gt; (select avg(inord.order_total)
                      from hive.orders inord
                      <span class="hljs-built_in">where</span> inord.state = o.state);
+----------+--------------+----------+
| cust_id  | order_total  | prod_id  |
+----------+--------------+----------+
| <span class="hljs-number">1328</span>     | <span class="hljs-number">73</span>           | <span class="hljs-number">26</span>       |
| <span class="hljs-number">1328</span>     | <span class="hljs-number">146</span>          | <span class="hljs-number">26</span>       |
| <span class="hljs-number">1328</span>     | <span class="hljs-number">56</span>           | <span class="hljs-number">26</span>       |
| <span class="hljs-number">1328</span>     | <span class="hljs-number">91</span>           | <span class="hljs-number">26</span>       |
| <span class="hljs-number">1328</span>     | <span class="hljs-number">74</span>           | <span class="hljs-number">26</span>       |
...
+----------+--------------+----------+
<span class="hljs-number">107</span>,<span class="hljs-number">482</span> rows selected (<span class="hljs-number">14.863</span> seconds)
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x6B63;&#x5728;&#x641C;&#x7D22;&#x7684;&#x4EA7;&#x54C1;&#x5217;&#x8868;&#xFF0C;&#x8FD9;&#x4E9B;&#x4EA7;&#x54C1;&#x4EF7;&#x683C;&#x662F;&#x9AD8;&#x4E8E;&#x5E73;&#x5747;&#x6C34;&#x5E73;&#x7684;&#x3002;</p>
<h3 id="&#x5B9E;&#x73B0;&#x9884;&#x89C8;&#x7ED3;&#x679C;">&#x5B9E;&#x73B0;&#x9884;&#x89C8;&#x7ED3;&#x679C;</h3>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; create table product_search as select o.cust_id, o.order_total, t.trans_info.prod_id[<span class="hljs-number">0</span>] as prod_id
from
hive.orders as o
join `clicks/clicks.json` t
on o.cust_id=t.user_info.cust_id
<span class="hljs-built_in">where</span> o.order_total &gt; (select avg(inord.order_total)
                      from hive.orders inord
                      <span class="hljs-built_in">where</span> inord.state = o.state);
+-----------+----------------------------+
| Fragment  | Number of records written  |
+-----------+----------------------------+
| <span class="hljs-number">0</span>_0       | <span class="hljs-number">107482</span>                     |
+-----------+----------------------------+
<span class="hljs-number">1</span> row selected (<span class="hljs-number">3.488</span> seconds)
</code></pre>
<p>&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x4F7F;&#x7528;&#x4E86;&#x4E00;&#x4E2A; <code>CTAS</code> &#x8BED;&#x6CD5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x8868;&#xFF0C;&#x57FA;&#x4E8E;&#x76F8;&#x5173;&#x5B50;&#x67E5;&#x8BE2;&#x3002;&#x8BE5;&#x8868;&#x5305;&#x542B;&#x6240;&#x6709;&#x7684;&#x67E5;&#x8BE2;&#x8FD4;&#x56DE;&#x7684;&#x884C;&#x6570;&#xFF08;107482&#xFF09;&#xFF0C;&#x5E76;&#x5C06;&#x5B83;&#x4EEC;&#x5B58;&#x50A8;&#x5728;&#x5B58;&#x50A8;&#x63D2;&#x4EF6;&#x6307;&#x5B9A;&#x7684;&#x683C;&#x5F0F;&#xFF08;&#x8BE5;&#x4F8B;&#x5B50;&#x4F7F;&#x7528;&#x7684;&#x662F; Parquet &#x683C;&#x5F0F;&#xFF09;&#x3002;&#x4F60;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x8868;&#xFF0C;&#x5E76;&#x4EE5; CSV&#xFF0C;Parquet &#x548C; JSON &#x683C;&#x5F0F;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x3002;</p>
<h3 id="&#x7EDF;&#x8BA1;&#x4E00;&#x4E2A;&#x65B0;&#x8868;&#x7684;&#x884C;&#x6570;">&#x7EDF;&#x8BA1;&#x4E00;&#x4E2A;&#x65B0;&#x8868;&#x7684;&#x884C;&#x6570;</h3>
<p>&#x8BE5;&#x4F8B;&#x5B50;&#x7B80;&#x5355;&#x7684;&#x68C0;&#x9A8C; <code>CTAS</code> &#x8BED;&#x6CD5;&#x7684;&#x6B63;&#x786E;&#x6027;&#x3002;</p>
<pre><code class="lang-bash"><span class="hljs-number">0</span>: jdbc:drill:&gt; select count(*) from product_search;
+---------+
| EXPR<span class="hljs-variable">$0</span>  |
+---------+
| <span class="hljs-number">107482</span>  |
+---------+
<span class="hljs-number">1</span> row selected (<span class="hljs-number">0.155</span> seconds)
</code></pre>
<h3 id="&#x627E;&#x51FA;&#x8868;&#x5B58;&#x50A8;&#x6587;&#x4EF6;&#xFF1A;">&#x627E;&#x51FA;&#x8868;&#x5B58;&#x50A8;&#x6587;&#x4EF6;&#xFF1A;</h3>
<pre><code class="lang-bash">[root@maprdemo product_search]<span class="hljs-comment"># cd /mapr/demo.mapr.com/data/nested/product_search</span>
[root@maprdemo product_search]<span class="hljs-comment"># ls -la</span>
total <span class="hljs-number">451</span>
drwxr-xr-x. <span class="hljs-number">2</span> mapr mapr      <span class="hljs-number">1</span> Sep <span class="hljs-number">15</span> <span class="hljs-number">13</span>:<span class="hljs-number">41</span> .
drwxr-xr-x. <span class="hljs-number">4</span> root root      <span class="hljs-number">2</span> Sep <span class="hljs-number">15</span> <span class="hljs-number">13</span>:<span class="hljs-number">41</span> ..
-rwxr-xr-x. <span class="hljs-number">1</span> mapr mapr <span class="hljs-number">460715</span> Sep <span class="hljs-number">15</span> <span class="hljs-number">13</span>:<span class="hljs-number">41</span> <span class="hljs-number">0</span>_0_0.parquet
</code></pre>
<p>&#x503C;&#x5F97;&#x6CE8;&#x610F;&#x7684;&#x662F;&#xFF0C;&#x8868;&#x5B58;&#x50A8;&#x5728;&#x4E00;&#x4E2A;&#x53EB; <code>0_0_0.parquet</code> &#x7684;&#x6587;&#x4EF6;&#x5F53;&#x4E2D;&#x3002;&#x8BE5;&#x6587;&#x4EF6;&#x5B58;&#x50A8;&#x5728;&#x672C;&#x5730;&#xFF0C;&#x7531; dfs.clicks &#x5DE5;&#x4F5C;&#x7A7A;&#x95F4;&#x5B9A;&#x4E49;&#x3002;</p>
<pre><code>&quot;location&quot;: &quot;http://demo.mapr.com/data/nested&quot;
</code></pre><p>&#x5728;&#x4F60;&#x521B;&#x5EFA;&#x7684;&#x8868;&#x4E2D;&#xFF0C;&#x6709;&#x4E00;&#x4E2A;&#x5177;&#x6709;&#x76F8;&#x540C;&#x540D;&#x79F0;&#x7684;&#x5B50;&#x76EE;&#x5F55;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; http://drill.smartloli.org 2016 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">Modify: 
2016-01-11 14:13:55
</span></footer>
                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/5.课程2:使用 ANSI SQL 查询.html" class="navigation navigation-prev " aria-label="Previous page: 5.课程2:使用 ANSI SQL 查询"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../3.教程/4.在 MapR 的 Sandbox 中学习 Drill/7.总结.html" class="navigation navigation-next " aria-label="Next page: 7.总结"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-baidu/plugin.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-livereload/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"tbfed-pagefooter":{"copyright":"Copyright &copy http://drill.smartloli.org 2016","modify_label":"Modify: ","modify_format":"YYYY-MM-DD HH:mm:ss"},"baidu":{"token":""},"fontsettings":{"size":1,"theme":"white","family":"sans"},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"livereload":{}};
    gitbook.start(config);
});
</script>

        <script>var _hmt = _hmt || [];(function() {var hm = document.createElement('script');hm.src = '//hm.baidu.com/hm.js?';var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(hm, s);})();</script>
    </body>
    
</html>
